VOISFloater =
{
    InformUserEventSrcElement : null,
    InformUserEventPageX : 0,
    InformUserEventPageY : 0,

    informingUserTimeout: null,
    informUserPausing: new Boolean(true),
    informUserSticking: new Boolean(false),
    infoDivId: new String("awwwe-browser-vois-wizard-info"),
    infoDivClassNameOff: new String("awwwe-browser-vois-wizard-info-off"),
    infoDivClassNameOn: new String("awwwe-browser-vois-wizard-info-on"),
    infoHeaderId: new String("awwwe-browser-vois-wizard-info-header-text"),
    infoXPathId1: new String("awwwe-browser-vois-wizard-info-xpath1"),
    infoXPathId2: new String("awwwe-browser-vois-wizard-info-xpath2"),
    infoXPathId3: new String("awwwe-browser-vois-wizard-info-xpath3"),
    infoVisualSayasModeButtonId: new String("awwwe-browser-vois-wizard-info-button-sayas-at-mode"),
    infoNodeModeButtonId: new String("awwwe-browser-vois-wizard-info-button-node-mode"),
    infoSayasAtEnterPId: new String("awwwe-browser-vois-wizard-info-sayas-at"),
    infoSelectVisualSpaceTypePId: new String("awwwe-browser-vois-wizard-info-visual-space-type"),
    infoXPathStickyButtonId: new String("awwwe-browser-vois-wizard-info-button-sticky"),
    infoXPathTestInputId: new String("awwwe-browser-vois-wizard-info-xpath-test"),
    infoXPathSayasInputId: new String("awwwe-browser-vois-wizard-info-sayas-at-say"),
    infoXPathHighlightButtonId: new String("awwwe-browser-vois-wizard-info-button-highlight"),
    infoXPathTestButtonId: new String("awwwe-browser-vois-wizard-info-button-test"),
    infoXPathAddButtonId: new String("awwwe-browser-vois-wizard-info-button-add"),
    infoXPathSelectId: new String("awwwe-browser-vois-wizard-info-select-field"),
    infoXPathVisualSayasId: new String("awwwe-browser-vois-wizard-info-visual-or-sayas-at"),
    infoMessagePId: new String("awwwe-browser-vois-wizard-info-message-p"),
    infoNodeInfoId: new String("awwwe-browser-vois-wizard-info-node-info-p"),
    infoXpathInputId: new String("awwwe-browser-vois-wizard-info-xpath-input"),
    infoXpathCloseButtonId: new String("awwwe-browser-vois-wizard-info-button-closer"),
    infoXpathVisualSpaceOkButtonId: new String("awwwe-browser-vois-wizard-info-button-visual-space-ok"),
    infoXpathSayasAtCancelButtonId: new String("awwwe-browser-vois-wizard-info-button-sayas-at-cancel"),
    infoXpathInspectElementOkButtonId: new String("awwwe-browser-vois-wizard-info-button-inspect-element-ok"),

    _lastMode : new String("visual"),
    _currentMode : new String("visual"),
    _lastVisualXpath : new String(""),
    _lastSayasAtXpath : new String(""),
    
    SetInfoHeader : function(text)
    {
        var hNode = document.getElementById(VOISFloater.infoHeaderId);
        for (var i=0; i<hNode.childNodes.length; i++)
        {
           if (hNode.childNodes[i].nodeType == 3)
            {
                hNode.childNodes[i].nodeValue = text;
                return;
            }
        }
        // not text child node
        var newTNode = document.createTextNode(text);
        hNode.appendChild(newTNode);
    },
    
    SetOnlySpeakAtOption : function(text)
    {
        var node = document.getElementById(VOISFloater.infoXPathSelectId);
        node.options[2].text = text;
        node.options[2].value = text;
    },

    UnInformUser : function()
    {
        VOISFloater._UnInformUser();
        VOISFloater.informUserPausing = true;
        // informingUserTimeout = setTimeout("VOISFloater.informUserPausing=false;", 1000);
    },

    _UnInformUser : function()
    {
        VOISFloater._InformUserStickyOff();
        VOISXPath._XPathTestHighlightWebPageUndo();
        node = document.getElementById(VOISFloater.infoXPathTestInputId);
        node.value = "";
        var div = document.getElementById(VOISFloater.infoDivId);
        div.setAttribute("class", VOISFloater.infoDivClassNameOff);
    },
    
    InformUserSticky : function()
    {
        // make the inform user hover div stick
        // so the user can use it to test expath expressions
        var node = document.getElementById(VOISFloater.infoXPathStickyButtonId);
        if (VOISFloater.informUserSticking == false)
        {
            VOISFloater._InformUserStickyOn();
        }
        else
        {
            VOISFloater._InformUserStickyOff();
        }
    },
    
    _InformUserStickyOn : function()
    {
        var node = document.getElementById(VOISFloater.infoXPathStickyButtonId);
        VOISFloater.informUserSticking = true;
        node.value = "Un Pin";
    },    
    
    _InformUserStickyOff : function()
    {
        var node = document.getElementById(VOISFloater.infoXPathStickyButtonId);
        VOISFloater.informUserSticking = false;
        node.value = "Pin";
    },
    
    InformUserBackFromInspectElement : function()
    {
        // set the state in the floating div
        var node, testnode;
        var xpath;
        // turn off the ok button
        node = document.getElementById(VOISFloater.infoXpathInspectElementOkButtonId);
        node.style.display = "none";
        node = document.getElementById(VOISFloater.infoXPathVisualSayasId);
        testnode = document.getElementById(VOISFloater.infoXPathTestInputId)
        node.value = VOISFloater._lastMode;
        if (VOISFloater._lastMode == "visual")
        {
            node = document.getElementById(VOISFloater.infoXPathSelectId);
            VOISXPath.convertXPathToCount = (node.selectedIndex == 0);
            node.onchange();
            testnode.value = VOISFloater._lastVisualXpath;
        }
        else
        {
            VOISXPath.convertXPathToCount = false;
            VOISFloater._InformUser();
            testnode.value = VOISFloater._lastSayasAtXpath;
        }
        // highlight
        node = document.getElementById(VOISFloater.infoXPathTestInputId);
        xpath = node.value.trim();
        node = document.getElementById(VOISFloater.infoXPathSelectId);
        if (xpath.length > 0 && node.selectedIndex > 0)
        {
        	VOISFloater.InformUserHighlightTestExpression();
        }
    },
    
    InformUserToggleVisualSayas : function()
    {
        // set the state in the floating div
        var node = document.getElementById(VOISFloater.infoXPathVisualSayasId);
        var testnode = document.getElementById(VOISFloater.infoXPathTestInputId);
        var xpath;
        VOISFloater._lastMode = node.value
        if (node.value == "visual")
        {
            VOISFloater._lastVisualXpath = testnode.value;
            node.value = "sayas";
            VOISXPath.convertXPathToCount = false;
            VOISFloater._lastVisualXpath
            VOISFloater._InformUser();
            testnode.value = VOISFloater._lastSayasAtXpath;
            node = document.getElementById(VOISFloater.infoXpathInspectElementOkButtonId);
            node.style.display = "none";
        }
        else
        {
            VOISFloater._lastSayasAtXpath = testnode.value;
            node.value = "visual";
            node = document.getElementById(VOISFloater.infoXPathSelectId);
            VOISXPath.convertXPathToCount = (node.selectedIndex == 0);
            node.onchange();
            testnode.value = VOISFloater._lastVisualXpath;
        }
        VOISFloater.SetAddButton();
        // highlight
        node = document.getElementById(VOISFloater.infoXPathTestInputId);
        xpath = node.value.trim();
        node = document.getElementById(VOISFloater.infoXPathSelectId);
        if (xpath.length > 0 && node.selectedIndex > 0)
        {
        	VOISFloater.InformUserHighlightTestExpression();
        }
    },
    
    SetAddButton : function()
    {
        var node, butnode, selnode;
        node = document.getElementById(VOISFloater.infoXPathVisualSayasId);
        butnode = document.getElementById(VOISFloater.infoXPathAddButtonId);
        selnode = document.getElementById(VOISFloater.infoXPathSelectId);
        if (node.value == "visual")
        {
        	butnode.value = "Add Expression to ".concat(selnode.options[selnode.selectedIndex].value);
        }
        else
        {
        	butnode.value = "Add the Sayas-at";
        }
    },
    
    InformUserVisualSpaceOn : function()
    {
        var node;
        var xpath;

        node = document.getElementById(VOISFloater.infoXPathVisualSayasId);
        node.value = "visual";

        // set the header in the floating div        
        VOISFloater.SetInfoHeader("Define A Visual Space");

        node = document.getElementById(VOISFloater.infoXPathId1);
        node.style.display = "block";
        node = document.getElementById(VOISFloater.infoXPathId2);
        node.style.display = "block";
        node = document.getElementById(VOISFloater.infoXPathId3);
        node.style.display = "block";
        
        // close button
        node = document.getElementById(VOISFloater.infoXpathCloseButtonId);
        node.style.display = "inline";
        
        // ok buttons
        node = document.getElementById(VOISFloater.infoXpathVisualSpaceOkButtonId);
        node.style.display = "none";
        node = document.getElementById(VOISFloater.infoXpathSayasAtCancelButtonId);
        node.style.display = "none";
        node = document.getElementById(VOISFloater.infoXpathInspectElementOkButtonId);
        node.style.display = "none";

        // xpath input textarea
        node = document.getElementById(VOISFloater.infoXpathInputId);
        node.style.display = "block";
        
        // display the visual section part of the floating div
        node = document.getElementById(VOISFloater.infoSelectVisualSpaceTypePId);
        node.style.display = "block";
        // undisplay the sayas say part of the floating div
        node = document.getElementById(VOISFloater.infoSayasAtEnterPId);
        node.style.display = "none";
        
        // set the onclick for visual spaces
        node = document.getElementById(VOISFloater.infoXPathAddButtonId);
        node.style.display = "inline";
        node.setAttribute("onclick", "VOISFloater.InformUserAddVisualSpaceTestExpression();");
        
        node = document.getElementById(VOISFloater.infoXPathSelectId);
        if (node.selectedIndex == 0)
        {
            // boolean
            // highlight button
            node = document.getElementById(VOISFloater.infoXPathHighlightButtonId);
            node.style.display = "none";
    
            // test button
            node = document.getElementById(VOISFloater.infoXPathTestButtonId);
            node.style.display = "inline";
        }
        else
        {
            // node sets
            // highlight button
            node = document.getElementById(VOISFloater.infoXPathHighlightButtonId);
            node.style.display = "inline";
    
            // test button
            node = document.getElementById(VOISFloater.infoXPathTestButtonId);
            node.style.display = "none";
        }

        // node info button
        node = document.getElementById(VOISFloater.infoNodeModeButtonId);
        node.style.display = "inline";
        
        // messages
        node = document.getElementById(VOISFloater.infoMessagePId);
        node.style.display = "none";
        
        // node info
        node = document.getElementById(VOISFloater.infoNodeInfoId);
        node.style.display = "none";

        // redisplay the xpaths
        // node = document.getElementById(VOISFloater.infoXPathSelectId);
        // node.onchange();

        // VOISFloater._InformUser();
        VOISFloater.SetAddButton();
        // highlight
        node = document.getElementById(VOISFloater.infoXPathTestInputId);
        xpath = node.value.trim();
        node = document.getElementById(VOISFloater.infoXPathSelectId);
        if (xpath.length > 0 && node.selectedIndex > 0)
        {
        	VOISFloater.InformUserHighlightTestExpression();
        }
    },    
    
    InformUserSayasAtOn : function()
    {
        var node, id;
        var xpath;

        // set the state in the floating div
        node = document.getElementById(VOISFloater.infoXPathVisualSayasId);
        node.value = "sayas";
        
        // set the header in the floating div        
        VOISFloater.SetInfoHeader("Define How To Say At");

        node = document.getElementById(VOISFloater.infoXPathId1);
        node.style.display = "block";
        node = document.getElementById(VOISFloater.infoXPathId2);
        node.style.display = "block";
        node = document.getElementById(VOISFloater.infoXPathId3);
        node.style.display = "block";
        
        // close button
        node = document.getElementById(VOISFloater.infoXpathCloseButtonId);
        node.style.display = "inline";
        // cancel button
        node = document.getElementById(VOISFloater.infoXpathSayasAtCancelButtonId);
        node.style.display = "inline";
        
        // ok buttons
        node = document.getElementById(VOISFloater.infoXpathVisualSpaceOkButtonId);
        node.style.display = "none";
        node = document.getElementById(VOISFloater.infoXpathInspectElementOkButtonId);
        node.style.display = "none";

        // xpath input textarea
        node = document.getElementById(VOISFloater.infoXpathInputId);
        node.style.display = "block";

        // undisplay the visual space select type part of the floating div
        node = document.getElementById(VOISFloater.infoSelectVisualSpaceTypePId);
        node.style.display = "none";
        // display the sayas say part of the floating div
        node = document.getElementById(VOISFloater.infoSayasAtEnterPId);
        node.style.display = "block";
        
        // set the onclick for sayas
        node = document.getElementById(VOISFloater.infoXPathAddButtonId);
        node.style.display = "inline";
        node.setAttribute("onclick", "VOISFloater.InformUserAddSayasAtTestExpression();");
        
        // highlight button
        node = document.getElementById(VOISFloater.infoXPathHighlightButtonId);
        node.style.display = "none";
        
        // test button
        node = document.getElementById(VOISFloater.infoXPathTestButtonId);
        node.style.display = "none";

        // hide the xpath nodes in the web page
        VOISXPath.XPathHighlightWebPageUndo();
        
        // turn on the sayas at section on the says page
        node = document.getElementById(VOISSayas.sayasAtSectionDivId);
        node.style.display = "block";
        
        // node info button
        node = document.getElementById(VOISFloater.infoNodeModeButtonId);
        node.style.display = "inline";
        
        // messages
        node = document.getElementById(VOISFloater.infoMessagePId);
        node.style.display = "none";
        
        // node info
        node = document.getElementById(VOISFloater.infoNodeInfoId);
        node.style.display = "none";
        
        // redisplay the new xpath expressions
        VOISXPath.convertXPathToCount = false;
        // VOISFloater._InformUser();
        // highlight
        node = document.getElementById(VOISFloater.infoXPathTestInputId);
        xpath = node.value.trim();
        if (xpath.length > 0)
        {
        	VOISFloater.InformUserHighlightTestExpression();
        }
    },    
    
    InformUserMessageOn : function(header, paragraph)
    {
        var node, stateNode;

        node = document.getElementById(VOISFloater.infoXPathId1);
        node.style.display = "none";
        node = document.getElementById(VOISFloater.infoXPathId2);
        node.style.display = "none";
        node = document.getElementById(VOISFloater.infoXPathId3);
        node.style.display = "none";

        node = document.getElementById(VOISFloater.infoDivId);
        node.setAttribute("class", VOISFloater.infoDivClassNameOn);

        // close button
        node = document.getElementById(VOISFloater.infoXpathCloseButtonId);
        node.style.display = "inline";
        
        // xpath input textarea
        node = document.getElementById(VOISFloater.infoXpathInputId);
        node.style.display = "none";
        node = document.getElementById(VOISFloater.infoXPathTestInputId);
        node.value = "";

        // set the header in the floating div        
        VOISFloater.SetInfoHeader(header);
        
        
        // display the visual section part of the floating div
        node = document.getElementById(VOISFloater.infoSelectVisualSpaceTypePId);
        node.style.display = "none";
        // undisplay the sayas say part of the floating div
        node = document.getElementById(VOISFloater.infoSayasAtEnterPId);
        node.style.display = "none";

        
        // set the onclick for sayas
        node = document.getElementById(VOISFloater.infoXPathAddButtonId);
        node.style.display = "none";
        

        // highlight button
        node = document.getElementById(VOISFloater.infoXPathHighlightButtonId);
        node.style.display = "none";

        // test button
        node = document.getElementById(VOISFloater.infoXPathTestButtonId);
        node.style.display = "none";
        
        // sayas say part of the floating div
        node = document.getElementById(VOISFloater.infoSayasAtEnterPId);
        node.style.display = "none";
        
        stateNode = document.getElementById(VOISFloater.infoXPathVisualSayasId);
        if (stateNode.value == "visual")
        {
            // mode buttons
            node = document.getElementById(VOISFloater.infoVisualSayasModeButtonId);
            node.style.display = "inline";
            // ok buttons
            node = document.getElementById(VOISFloater.infoXpathVisualSpaceOkButtonId);
            node.style.display = "inline";
            // sayas at cancel button
            node = document.getElementById(VOISFloater.infoXpathSayasAtCancelButtonId);
            node.style.display = "none";
        }
        else if (stateNode.value == "sayas")
        {
            // mode buttons
            node = document.getElementById(VOISFloater.infoVisualSayasModeButtonId);
            node.style.display = "inline";
            // ok buttons
            node = document.getElementById(VOISFloater.infoXpathVisualSpaceOkButtonId);
            node.style.display = "none";
            // sayas at cancel button
            node = document.getElementById(VOISFloater.infoXpathSayasAtCancelButtonId);
            node.style.display = "inline";
        }
        node = document.getElementById(VOISFloater.infoNodeModeButtonId);
        node.style.display = "block";
        
        // messages
        node = document.getElementById(VOISFloater.infoMessagePId);
        node.innerHTML = paragraph;
        //VOISXml.ReplaceInnerText(node, paragraph);
        node.style.display = "block";
        
        // node info
        node = document.getElementById(VOISFloater.infoNodeInfoId);
        node.style.display = "none";
    },    
    
    InformUserNodeInfoOn : function()
    {
        var node, testnode, stateNode;
        node = document.getElementById(VOISFloater.infoXPathVisualSayasId);
        testnode = document.getElementById(VOISFloater.infoXPathTestInputId);
        VOISFloater._lastMode = node.value
        if (node.value == "visual")
        {
            VOISFloater._lastVisualXpath = testnode.value;
        }
        else
        {
            VOISFloater._lastSayasAtXpath = testnode.value;
        }

        node = document.getElementById(VOISFloater.infoXPathId1);
        node.style.display = "none";
        node = document.getElementById(VOISFloater.infoXPathId2);
        node.style.display = "none";
        node = document.getElementById(VOISFloater.infoXPathId3);
        node.style.display = "none";

        node = document.getElementById(VOISFloater.infoDivId);
        node.setAttribute("class", VOISFloater.infoDivClassNameOn);
        
        // close button
        node = document.getElementById(VOISFloater.infoXpathCloseButtonId);
        node.style.display = "inline";
        // ok button
        node = document.getElementById(VOISFloater.infoXpathInspectElementOkButtonId);
        node.style.display = "inline";
        
        // xpath input textarea
        node = document.getElementById(VOISFloater.infoXpathInputId);
        node.style.display = "none";

        // set the header in the floating div        
        VOISFloater.SetInfoHeader("Inspect Element.");
        
        // display the visual section part of the floating div
        node = document.getElementById(VOISFloater.infoSelectVisualSpaceTypePId);
        node.style.display = "none";
        // undisplay the sayas say part of the floating div
        node = document.getElementById(VOISFloater.infoSayasAtEnterPId);
        node.style.display = "none";
        
        // set the onclick for sayas
        node = document.getElementById(VOISFloater.infoXPathAddButtonId);
        node.style.display = "none";
        

        // highlight button
        node = document.getElementById(VOISFloater.infoXPathHighlightButtonId);
        node.style.display = "none";

        // test button
        node = document.getElementById(VOISFloater.infoXPathTestButtonId);
        node.style.display = "none";
        
        // sayas say part of the floating div
        node = document.getElementById(VOISFloater.infoSayasAtEnterPId);
        node.style.display = "none";

        stateNode = document.getElementById(VOISFloater.infoXPathVisualSayasId);
        if (stateNode.value == "visual")
        {
            // mode buttons
            node = document.getElementById(VOISFloater.infoVisualSayasModeButtonId);
            node.style.display = "inline";
            // ok buttons
            node = document.getElementById(VOISFloater.infoXpathVisualSpaceOkButtonId);
            node.style.display = "none";
            // sayas at cancel button
            node = document.getElementById(VOISFloater.infoXpathSayasAtCancelButtonId);
            node.style.display = "none";
        }
        else if (stateNode.value == "sayas")
        {
            // mode buttons
            node = document.getElementById(VOISFloater.infoVisualSayasModeButtonId);
            node.style.display = "inline";
            // ok buttons
            node = document.getElementById(VOISFloater.infoXpathVisualSpaceOkButtonId);
            node.style.display = "none";
            node = document.getElementById(VOISFloater.infoXpathSayasAtCancelButtonId);
            node.style.display = "none";
        }
        node = document.getElementById(VOISFloater.infoNodeModeButtonId);
        node.style.display = "none";
        
        // messages
        node = document.getElementById(VOISFloater.infoMessagePId);
        node.style.display = "none";
        
        // node info
        node = document.getElementById(VOISFloater.infoNodeInfoId);
        node.style.display = "block";
        VOISFloater._InformUserNodeInfo(node);
    },    

    InformUserAddVisualSpaceTestExpression : function()
    {
        // add the xpath expression
        var ok;
        var node = document.getElementById(VOISFloater.infoXPathTestInputId);
        var xpath = node.value.trim();
        if (xpath.length > 0)
        {
        	if (VOISXPath.convertXPathToCount)
            {
	            ok = VOISXPath.IsValidXpathExpressionBoolean(xpath);
            }
            else
            {
	            ok = VOISXPath.IsValidXpathExpressionNodeSet(xpath);
            }
            if (ok.isValid)
            {
                VOISFloater.PasteVisualSpaceXpath(xpath);
                VOISFloater.InformUserMessageOn("Success", "Your xpath expression been added.");
                // clear the stored xpath expression.
		        node = document.getElementById(VOISFloater.infoXPathVisualSayasId);
                if (node.value == "visual")
                {
                	VOISFloater._lastVisualXpath = new String();
                }
                else
                {
                	VOISFloater._lastSayasAtXpath = new String();
                }
            }
            else
            {
                VOISFloater.InformUserMessageOn("Oops", ok.message);
                node.value = xpath;
            }
        }
        else
        {
            VOISFloater.InformUserMessageOn("Oops", "Select an xpath expression first.");
        }
    },

    InformUserAddSayasAtTestExpression : function()
    {
        // add the xpath expression
        var ok;
        var node = document.getElementById(VOISFloater.infoXPathTestInputId);
        var xpath = node.value.trim();
        if (xpath.length > 0)
        {
            ok = VOISXPath.IsValidXpathExpressionNodeSet(xpath);
            if (ok.isValid)
            {
                // get what to say
                var sNode = document.getElementById(VOISFloater.infoXPathSayasInputId);
                var sayas = sNode.value.trim();
                sNode.value = "";
                // add the new sayas at section to the form
                VOISSayas.AddSectionSayasAt(sayas, xpath);
                VOISFloater.InformUserMessageOn("Success", "Your sayas at has been added.");
            }
            else
            {
                VOISFloater.InformUserMessageOn("Not Valid", "That is not a valid xpath expression.<br/><br/>" + ok.message);
                node.value = xpath;
            }
        }
        else
        {
            VOISFloater.InformUserMessageOn("Oops", "Select an xpath expression first.");
        }
    },
    
    InformUserHighlightTestExpression : function()
    {
        var ok;
        var node = document.getElementById(VOISFloater.infoXPathTestInputId);
        var xpath = node.value.trim();
        if (xpath.length > 0)
        {
            ok = VOISXPath.IsValidXpathExpressionNodeSet(xpath);
            if (ok.isValid)
            {
                if (VOISEditor.currentlySelectedNode != null)
                {
                    VOISXPath.XPathHighlightWebPage(VOISEditor.currentlySelectedNode.getAttribute("id"));
                    VOISXPath.XPathTestHighlightWebPage(xpath);
                }
                else if (VOISFloater.currentlySelectedSayasAtNode != null)
                {
                    VOISXPath.XPathHighlightWebPage(VOISFloater.currentlySelectedSayasAtNode.getAttribute("id"));
                    VOISXPath.XPathTestHighlightWebPage(xpath);
                }
            }
            else
            {
                VOISFloater.InformUserMessageOn("Not Valid", "That is not a valid xpath expression.<br/><br/>" + ok.message);
                node.value = xpath;
            }
        }
        else
        {
            VOISFloater.InformUserMessageOn("Oops", "Select an xpath expression first.");
        }
    },
    
    InformUserTestBooleanExpression : function()
    {
        var ok;
        var node = document.getElementById(VOISFloater.infoXPathTestInputId);
        var xpath = node.value.trim();
        if (xpath.length > 0)
        {
            ok = VOISXPath.IsValidXpathExpressionBoolean(xpath);
            if (ok.isValid)
            {
                VOISFloater.InformUserMessageOn(
                    "Valid",
                    "The XPath Boolean Expresssion<br /><br />" + xpath + "<br /><br />returns " + ok.isTrue.toString() + ".");
                node.value = xpath;
            }
            else
            {
                VOISFloater.InformUserMessageOn("Not Valid", "That is not a valid XPath Boolean Expresssion.<br/><br/>" + ok.message);
                node.value = xpath;
            }
        }
        else
        {
            VOISFloater.InformUserMessageOn("Oops", "Select an XPath Boolean Expresssion first.");
        }
    },
    
    CopyXpathToTest : function(xpath)
    {
        // copy the xpath to the test input field so the user can test it.
        // highlight it.
        var node = document.getElementById(VOISFloater.infoXPathTestInputId);
        node.value = xpath;
        VOISXPath.XPathTestHighlightWebPage(xpath);
    },

    PasteSayasAtXpath : function(xpath)
    {
        // copy the xpath to the form
        var xpathTrimmed = xpath.trim();
        
        // get the sayas at at node in the form
        var sayasAtDivId = VOISFloater.currentlySelectedSayasAtNode.getAttribute("id");
        var sayasAtAtId = VOISFloater.BuildSayasAtAtId(sayasAtDivId);
        var sayasAtAtNode = document.getElementById(sayasAtAtId);
        var fullExpression = sayasAtAtNode.value.trim();
        
        var splitter = " | ";
        var joiner = "\r\n" + splitter;
        var expressions = fullExpression.split(splitter);
        if (expressions.length > 0)
        {
            // there are xpaths already in the form field.
            // add but don't duplicate xpathTrimmed
            var i = 0;
            var removed = false;
            while (i < expressions.length)
            {
                var exp = expressions[i].trim();
                if (exp.length == 0)
                {
                    expressions.splice(i, 1);
                }
                else if (exp.length > 0 && exp == xpathTrimmed)
                {
                    expressions.splice(i, 1);
                    removed = true;
                }
                else
                {
                    i++;
                }
            }
            if (removed == false)
            {
                expressions.push(xpathTrimmed);
            }
            sayasAtAtNode.value = expressions.join(joiner);
        }
        else
        {
            // this is the first xpath for the form field.
            sayasAtAtNode.value = xpathTrimmed;
        }
        // VOISFloater._UnInformUser();
        // hightlight the xpaths in the web page
        // VOISXPath.XPathHighlightWebPage(VOISFloater.currentlySelectedSayasAtNode.getAttribute("id"));
    },

    PasteVisualSpaceXpath : function(xpath)
    {
        // copy the xpath to the form
        var node;
        var xpathTrimmed = xpath.trim();
        var fullExpression = VOISEditor.currentlySelectedNode.value.trim();
        var splitter;
        if (VOISXPath.convertXPathToCount == false)
        {
            splitter = " | ";
        }
        else
        {
            splitter = " and ";
        }
        var joiner = "\r\n" + splitter;
        var expressions = fullExpression.split(splitter);
        if (expressions.length > 0)
        {
            // there are xpaths already in the form field.
            // add but don't duplicate xpathTrimmed
            var i = 0;
            var removed = false;
            while (i < expressions.length)
            {
                var exp = expressions[i].trim();
                if (exp.length == 0)
                {
                    expressions.splice(i, 1);
                }
                else if (exp.length > 0 && exp == xpathTrimmed)
                {
                    expressions.splice(i, 1);
                    removed = true;
                }
                else
                {
                    i++;
                }
            }
            if (removed == false)
            {
                expressions.push(xpathTrimmed);
            }
            VOISEditor.currentlySelectedNode.value = expressions.join(joiner);
        }
        else
        {
            // this is the first xpath for the form field.
            VOISEditor.currentlySelectedNode.value = xpathTrimmed;
        }
        // VOISFloater._UnInformUser();
        node = document.getElementById(VOISFloater.infoXPathSelectId);
        if (node.selectedIndex > 0)
        {
            // not a boolean xpath but a node set xpath
            // hightlight the xpaths in the web page
            VOISXPath.XPathHighlightWebPage(VOISEditor.currentlySelectedNode.getAttribute("id"));
        }
    },

    InformUserClear : function(id)
    {
        var node = document.getElementById(id);
        for (var i=node.childNodes.length-1; i>=0; i--)
		{
            if (node.childNodes[i].nodeType == 3)
            {
                node.childNodes[i].nodeValue = "";
                break;
            }
		}
        if (i < 0)
        {
            node.appendChild(document.createTextNode(""));
        }
        node.removeAttribute("onclick");
    },

    InformUserAddXPath : function(xpath, id)
    {
        var node = document.getElementById(id);
        for (var i=node.childNodes.length-1; i>=0; i--)
		{
            if (node.childNodes[i].nodeType == 3)
            {
                node.childNodes[i].nodeValue = xpath;
                break;
            }
		}
        if (i < 0)
        {
            node.appendChild(document.createTextNode(xpath));
        }
        node.setAttribute("onclick", "VOISFloater.CopyXpathToTest(\"" + xpath + "\");");
    },
    
    CopyToClipBoard : function(e, desc, text)
    {
        window.prompt ("Copy " + desc + " to the clipboard: Ctrl+C, Enter", text);
    },
    
    InformUserOpen : function(e)
    {
        if (!e) var e = window.event;

        VOISFloater.informUserPausing = false;
        VOISFloater.InformUser(e);
    },
    
    InformUser : function(e)
    {
        if (!e) var e = window.event;
        var div = document.getElementById(VOISFloater.infoDivId);
        var src = e.target || e.srcElement;
        if (div != src)
        {
            if (VOISFloater.informUserSticking == false)
            {
                VOISFloater.InformUserEventSrcElement = src;
                VOISFloater.InformUserEventPageX = e.pageX;
                VOISFloater.InformUserEventPageY = e.pageY;
                VOISFloater._InformUser();
                // clear the text inputs for visual and sayas
                VOISFloater._lastSayasAtXpath = new String("");
                VOISFloater._lastVisualXpath = new String("");
                node = document.getElementById(VOISFloater.infoXPathSayasInputId);
                node.value = new String("");
            }
        }
    },
    
    _InformUserNodeInfo : function (targetNode)
    {
        var i, text, isHtmlBody, attributes;
        // clear
        for (i=targetNode.childNodes.length-1; i>=0; i--)
        {
            if (targetNode.childNodes[i].nodeType == 1 || targetNode.childNodes[i].nodeType == 3 || targetNode.childNodes[i].nodeType == 4)
            {
                targetNode.removeChild(targetNode.childNodes[i]);
            }
        }

        // get the attributes and determine if this is the work area div
        attributes = new Array();
        isHtmlBody = false;
        if (VOISFloater.InformUserEventSrcElement != null)
        {
            if (VOISFloater.InformUserEventSrcElement.hasAttributes())
            {
                var atts = VOISFloater.InformUserEventSrcElement.attributes;
                for (i=0; i<atts.length; i++)
                {
                    if (atts[i].localName != "style" && atts[i].localName != "x-awwwe-browser-id" && atts[i].localName != "onclick")
                    {
                        if (! (atts[i].localName == "id" && atts[i].nodeValue == VOISEditor.wrapperWorkAreaDivId) )
                        {
                            attributes.push(atts[i].localName + " = \"" + atts[i].nodeValue + "\"");
                        }
                        else
                        {
                            isHtmlBody = true;
                            break;
                        }
                    }
                }
            }
        }
        if (isHtmlBody)
        {
            // fake html body
            try
            {
                text = document.createCDATASection("<");
                targetNode.appendChild(text);
                if (VOISXPath.rootPrefix.length > 0)
                {
                    text = document.createTextNode(VOISXPath.rootPrefix);
                    targetNode.appendChild(text);
                }
                text = document.createTextNode("html");
                targetNode.appendChild(text);
                text = document.createCDATASection("><");
                targetNode.appendChild(text);
                if (VOISXPath.rootPrefix.length > 0)
                {
                    text = document.createTextNode(VOISXPath.rootPrefix);
                    targetNode.appendChild(text);
                }
                text = document.createTextNode("body");
                targetNode.appendChild(text);
                text = document.createCDATASection(">");
                targetNode.appendChild(text);
            }
            catch (e)
            {
                text = document.createTextNode("<");
                targetNode.appendChild(text);
                if (VOISXPath.rootPrefix.length > 0)
                {
                    text = document.createTextNode(VOISXPath.rootPrefix);
                    targetNode.appendChild(text);
                }
                text = document.createTextNode("html");
                targetNode.appendChild(text);
                text = document.createTextNode("><");
                targetNode.appendChild(text);
                if (VOISXPath.rootPrefix.length > 0)
                {
                    text = document.createTextNode(VOISXPath.rootPrefix);
                    targetNode.appendChild(text);
                }
                text = document.createTextNode("body");
                targetNode.appendChild(text);
                text = document.createTextNode(">");
                targetNode.appendChild(text);
            }
        }
        else
        {
            // the name of the tag
            try
            {
                text = document.createCDATASection("<");
            }
            catch (e)
            {
                text = document.createTextNode("<");
            }
            targetNode.appendChild(text);
            text = document.createTextNode(VOISFloater.InformUserEventSrcElement.localName);
            targetNode.appendChild(text);
            // attributes
            if (attributes.length > 0)
            {
                var ul = document.createElement("ul");
                for (i=0; i<attributes.length; i++)
                {
                    var li = document.createElement("li");
                    text = document.createTextNode(attributes[i]);
                    li.appendChild(text);
                    ul.appendChild(li);
                }
                targetNode.appendChild(ul);
            }
            // end the tag
            try
            {
                text = document.createCDATASection(">");
            }
            catch (e)
            {
                text = document.createTextNode(">");
            }
            targetNode.appendChild(text);
        }
    },
    
    _InformUser : function()
    {
        var div, level, name, i;
        
        if (
            VOISFloater.informUserPausing == false
            &&
            VOISEditor.currentlySelectedNode != null
            // ( VOISEditor.currentlySelectedNode != null || VOISFloater.currentlySelectedSayasAtNode != null)
        )
        {
            name = VOISFloater.InformUserEventSrcElement.tagName.toLowerCase();
            i = name.indexOf(":");
            if (i>=0)
            {
                name = name.substring(++i);
            }
            if (name == "a")
            {
                // dont index anchor tags at level 0
                // index them at their parent
                level = 1
            }
            else
            {
                // index divs and others at the right most tag name
                // except for counts
                level = (VOISXPath.convertXPathToCount == true) ? (1) : (0);
            }
        
            // the user is moused over part of the web page.
            // add the xpath to the div
            // first path
            var xpath1 = VOISXPath.BuildXPath(VOISFloater.InformUserEventSrcElement, level);
            var cleanXpath = xpath1.replace(/"/g, "\\\"");
            if (VOISXPath.convertXPathToCount == true)
            {
                // convert the epath to a count
                cleanXpath = "count(" + cleanXpath + ")=1";
            }
            VOISFloater.InformUserAddXPath(cleanXpath, VOISFloater.infoXPathId1);
            // second xpath if it is different than the first path
            var xpath2 = VOISXPath.BuildXPath(VOISFloater.InformUserEventSrcElement, ++level);
            if (xpath2 != xpath1)
            {
                cleanXpath = xpath2.replace(/"/g, "\\\"");
                if (VOISXPath.convertXPathToCount == true)
                {
                    // convert the epath to a count
                    cleanXpath = "count(" + cleanXpath + ")=1";
                }
                VOISFloater.InformUserAddXPath(cleanXpath, VOISFloater.infoXPathId2);
                // third xpath if it is different than the second path
                var xpath3 = VOISXPath.BuildXPath(VOISFloater.InformUserEventSrcElement, ++level);
                if (xpath3 != xpath2)
                {
                    cleanXpath = xpath3.replace(/"/g, "\\\"");
                    if (VOISXPath.convertXPathToCount == true)
                    {
                        // convert the epath to a count
                        cleanXpath = "count(" + cleanXpath + ")=1";
                    }
                    VOISFloater.InformUserAddXPath(cleanXpath, VOISFloater.infoXPathId3);
                }
                else
                {
                    // not using the last path
                    VOISFloater.InformUserClear(VOISFloater.infoXPathId3);
                }
            }
            else
            {
                // not using the last 2 paths
                VOISFloater.InformUserClear(VOISFloater.infoXPathId2);
                VOISFloater.InformUserClear(VOISFloater.infoXPathId3);
            }

            // set the div location
            // VOISFloater.InformUserEventPageX // left 
            // VOISFloater.InformUserEventPageY // down
            // calc x
            var x = VOISFloater.InformUserEventPageX;
            if ((VOISFloater.InformUserEventPageX - window.pageXOffset) + 600 > window.innerWidth)
            {
                x = VOISFloater.InformUserEventPageX - 600;
            }
            else
            {
                x = VOISFloater.InformUserEventPageX;
            }
            var y = VOISFloater.InformUserEventPageY;
            if ((VOISFloater.InformUserEventPageY - window.pageYOffset) < 600)
            {
                y = window.pageYOffset;
            }
            else if ((VOISFloater.InformUserEventPageY - window.pageYOffset) + 600 > window.innerHeight)
            {
                y = VOISFloater.InformUserEventPageY - 600;
            }
            else
            {
                y = VOISFloater.InformUserEventPageY;
            }
            div = document.getElementById(VOISFloater.infoDivId);
            div.style.left = x.toString() + "px";
            div.style.top = y.toString() + "px";
            div.setAttribute("class", VOISFloater.infoDivClassNameOn);

            // undo the test highlighting in the web page
            VOISXPath._XPathTestHighlightWebPageUndo();
            // clear the test text area
            node = document.getElementById(VOISFloater.infoXPathTestInputId);
            node.value = "";
            node = document.getElementById(VOISFloater.infoXPathVisualSayasId);
            if (node.value == "sayas")
            {
                VOISFloater.InformUserSayasAtOn();
            }
            else
            {
                VOISFloater.InformUserVisualSpaceOn();
            }
            
        }
    },
};